const { dialog } = require('electron')

module.exports = mainWindow => {
  return {
    label: '打开',
    submenu: [
      {
        label: '打开文件',
        click: () => {
          dialog
            .showOpenDialog({
              defaultPath: __dirname,
              properties: ['openFile'],
            })
            .then(fileObj => {
              console.log(fileObj)
              mainWindow.webContents.send('FILE_OPEN', fileObj.filePaths)
            })
            .catch(err => {
              console.log(err)
            })
        },
      },
    ],
  }
}
